<template>
  <el-dialog
    :visible.sync="dialogVisible"
    :title="title"
    :width="width"
    :top="top"
    @closed="handleClose"
    :modal="false"
    :append-to-body="true"
    :modal-append-to-body="false"
    :close-on-click-modal="false"
    destroy-on-close
  >
    <div class="dialog_main">
      <slot></slot>
    </div>
    <footer class="dialog_footer" v-if="BtnShow">
      <el-button size="mini" @click="handleClose">取 消</el-button>
      <el-button size="mini" type="primary" @click="handleSubmit">确 定</el-button>
    </footer>
  </el-dialog>
</template>

<script>
export default {
  name: "Dialog",
  props: {
    title: {
      type: String,
      default: ""
    },
    width: {
      type: String,
      default: "25%"
    },
    top: {
      type: String,
      default: "15vh"
    },
    // dialogVisible: {
    //   type: Boolean,
    //   default: false
    // },
    BtnShow: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      dialogVisible: false
    }
  },
  methods: {
    handleClose() {
      this.dialogVisible = false
      this.$emit("handleClose", false)
    },

    // 提交表单
    handleSubmit() {
      this.$emit("handleSubmit")
    }
  }
}
</script>

<style lang="scss" scoped>
.dialog_main {
  margin-bottom: 30px;
}
.dialog_footer {
  text-align: right;
}
</style>
